package com.fiberhome.platform.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fiberhome.platform.common.EUTreeNode;
import com.fiberhome.platform.common.PageResult;
import com.fiberhome.platform.pojo.NeedCategory;
import com.fiberhome.platform.pojo.TestCategory;
import com.fiberhome.platform.service.NeedCatService;
import com.fiberhome.platform.service.TestCatService;



/**
 * @Description 关于设计需求分类列表和测试用例分类列表的controller
 * @author 龚洪亮
 * @version 2017年8月8日
 */
@Controller
public class CatController {
	@Autowired
	private NeedCatService needCatService;
	
	@Autowired
	private TestCatService testCatService;
	/**
	 * Description 获取需求的分类
	 * Date 2017年8月8日
	 * @param parentId
	 * @return
	 */
	@RequestMapping("/need/category/list")
	@ResponseBody
	public List<EUTreeNode> getNeedCat(@RequestParam(value="id", defaultValue="0") Integer parentId) {
		return needCatService.getNeedCat(parentId);
	}
	
	
	
	
	@RequestMapping(value="/need/category/create", method=RequestMethod.POST)
	@ResponseBody
	public PageResult createNeed(NeedCategory need) {
		
		return needCatService.createNeed(need);
		
	}
	
	@RequestMapping(value="/need/category/update", method=RequestMethod.POST)
	@ResponseBody
	public PageResult updateNeed(NeedCategory need) {
		return needCatService.updateNeed(need);
	}
	
	@RequestMapping(value="/need/category/delete", method=RequestMethod.POST)
	@ResponseBody
	public PageResult deleteNeed(Integer id, String designNo) {
		return needCatService.deleteNeed(id,designNo);
	}
	
	
	@RequestMapping(value="/test/category/create", method=RequestMethod.POST)
	@ResponseBody
	public PageResult createTest(TestCategory test) {
		
		return testCatService.createTest(test);
		
	}
	
	@RequestMapping(value="/test/category/update", method=RequestMethod.POST)
	@ResponseBody
	public PageResult updateTest(TestCategory testCat) {
		return testCatService.updateTest(testCat);
	}
	
	@RequestMapping(value="/test/category/delete", method=RequestMethod.POST)
	@ResponseBody
	public PageResult deleteTest(Integer id, String caseNo) {
		return testCatService.deleteTest(id, caseNo);
	}
	
	
	/**
	 * Description 获取测试用例分类
	 * Date 2017年8月8日
	 * @param parentId
	 * @return
	 */
	@RequestMapping("/test/category/list")
	@ResponseBody
	public List<EUTreeNode> getTestCat(@RequestParam(value="id", defaultValue="0") Integer parentId) {
		return testCatService.getTestCat(parentId);
	}
}
